home *** CD-ROM | disk | FTP | other *** search
- Path: hal.COM!spike
- From: spike@hal.com (Spike White)
- Newsgroups: comp.lang.c++
- Subject: Re: Leap year
- Date: 28 Mar 1996 16:58:14 GMT
- Organization: HAL Computer Systems, Inc.
- Message-ID: <4jegf6$7d2@news.hal.com>
- References: <3135A7F2.2120@hiwaay.net> <4hbiln$899@sam.inforamp.net> <4hesba$ph@clarknet.clark.net> <3146D0D8.16BA@msn.com> <4ilcd9$3q0@clarknet.clark.net> <31596B2F.5219@mail.tju.edu>
- NNTP-Posting-Host: zarathustra.hal.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Sukumar Patel (Sukumar.Patel@mail.tju.edu) wrote:
- : Harlan Messinger wrote:
- : >
- : > Poul A. Costinsky (PoulACost@msn.com) wrote:
- : > : return (!(y % 4) && (y % 100));
- : > :
- : >
- : > BZZT! But thanks for playing... ;-)
- : >
- : > (Hint: 2000 will be a leap year.)
-
-
- : That should probably be:
- : return (!(y % 4) && (y % 400));
-
- No, because 1800, 1900 and 2100 are not leap years. The rule is:
- "every 4 yrs, except for every 100 yrs, except for every 400 yrs". In
- C, that's
-
- return (!(y % 4) && ((y % 100) || !(y % 400)));
-
- and that doesn't even account for the Gregorian calendar (used before
- 1752).
-
- --
- Spike White | spike@hal.com | Biker Nerds
- HaL Software Systems | '87 BMW K75S, DoD #1347 | From HaL
- Austin, TX | http://www.halsoft.com/users/spike/index.html
- Disclaimer: HaL, want me to speak for you? No, Dave...
-